<html>
<!-- =====================================================================

  File:      Generated file for Adventure Works Cycles Storefront Sample
  Summary:   Self-documentation for application
  Date:	     June 16, 2003

=====================================================================

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) 2003 Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= -->
<head>
  <link rel=stylesheet href=style.css>
</head>
<body>
<div class=SourcePanel style="font-size:12">
<pre style="background-color:white">
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Collections</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">ComponentModel</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Data</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Data</span>.<span style="color: #2040a0">SqlClient</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Drawing</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Web</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Web</span>.<span style="color: #2040a0">SessionState</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Web</span>.<span style="color: #2040a0">UI</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Web</span>.<span style="color: #2040a0">UI</span>.<span style="color: #2040a0">WebControls</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Web</span>.<span style="color: #2040a0">UI</span>.<span style="color: #2040a0">HtmlControls</span><span style="color: #4444FF">;</span>

<span style="color: #008000">/* =====================================================================

  File:      OrderList.aspx for Adventure Works Cycles Storefront Sample
  Summary:   Lists a brief summary of all orders for the authenticated user
  Date:	     June 16, 2003

---------------------------------------------------------------------

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED &quot;AS IS&quot; WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= */</span>

<span style="color: #0000FF"><strong>namespace</strong></span> <span style="color: #2040a0">Microsoft</span>.<span style="color: #2040a0">Samples</span>.<span style="color: #2040a0">SqlServer</span> <span style="color: #4444FF"><strong>{</strong></span>

    <span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">partial</span> <span style="color: #0000FF"><strong>class</strong></span> <span style="color: #2040a0">OrderList</span> <span style="color: #4444FF">:</span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Web</span>.<span style="color: #2040a0">UI</span>.<span style="color: #2040a0">Page</span>
    <span style="color: #4444FF"><strong>{</strong></span>

    
<span style="color: #008000">//         public OrderList() {</span>
<span style="color: #008000">//             Page.Init += new System.EventHandler(Page_Init);</span>
<span style="color: #008000">//         }</span>

        <span style="color: #008000">//*******************************************************</span>
        <span style="color: #008000">//</span>
        <span style="color: #008000">// The Page_Load event on this page is used to obtain</span>
        <span style="color: #008000">// from a database a collection of all orders placed</span>
        <span style="color: #008000">// by the current customer, and the customer account details.  </span>
		<span style="color: #008000">// The collection of orders is then</span>
        <span style="color: #008000">// databound to a templated asp:datalist control.</span>
        <span style="color: #008000">//</span>
        <span style="color: #008000">//*******************************************************</span>

        <span style="color: #0000FF"><strong>private</strong></span> <span style="color: #0000FF"><strong>void</strong></span> <span style="color: #2040a0">Page_Load</span><span style="color: #4444FF">(</span><span style="color: #2040a0">object</span> <span style="color: #2040a0">sender</span>, <span style="color: #2040a0">System</span>.<span style="color: #2040a0">EventArgs</span> <span style="color: #2040a0">e</span><span style="color: #4444FF">)</span> <span style="color: #4444FF"><strong>{</strong></span>

            <span style="color: #2040a0">String</span> <span style="color: #2040a0">customerID</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">User</span>.<span style="color: #2040a0">Identity</span>.<span style="color: #2040a0">Name</span><span style="color: #4444FF">;</span>

            <span style="color: #008000">// Obtain and bind a list of all orders ever placed by visiting customer</span>
            <span style="color: #2040a0">OrdersDB</span> <span style="color: #2040a0">orderHistory</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">OrdersDB</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
        
            <span style="color: #2040a0">MyList</span>.<span style="color: #2040a0">DataSource</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">orderHistory</span>.<span style="color: #2040a0">GetCustomerOrders</span><span style="color: #4444FF">(</span><span style="color: #2040a0">customerID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">MyList</span>.<span style="color: #2040a0">DataBind</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

            <span style="color: #008000">// Hide the list and display a message if no orders have ever been made</span>
            <span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">MyList</span>.<span style="color: #2040a0">Items</span>.<span style="color: #2040a0">Count</span> <span style="color: #4444FF">=</span><span style="color: #4444FF">=</span> <span style="color: #FF0000">0</span><span style="color: #4444FF">)</span> <span style="color: #4444FF"><strong>{</strong></span>
                <span style="color: #2040a0">MyError</span>.<span style="color: #2040a0">Text</span> <span style="color: #4444FF">=</span> <span style="color: #444444">&quot;You have no orders to display.&quot;</span><span style="color: #4444FF">;</span>
                <span style="color: #2040a0">MyList</span>.<span style="color: #2040a0">Visible</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>false</strong></span><span style="color: #4444FF">;</span>
            <span style="color: #4444FF"><strong>}</strong></span>
        <span style="color: #4444FF"><strong>}</strong></span>

        <span style="color: #0000FF"><strong>private</strong></span> <span style="color: #0000FF"><strong>void</strong></span> <span style="color: #2040a0">Page_Init</span><span style="color: #4444FF">(</span><span style="color: #2040a0">object</span> <span style="color: #2040a0">sender</span>, <span style="color: #2040a0">EventArgs</span> <span style="color: #2040a0">e</span><span style="color: #4444FF">)</span> <span style="color: #4444FF"><strong>{</strong></span>
            <span style="color: #008000">//</span>
            <span style="color: #008000">// CODEGEN: This call is required by the ASP.NET Web Form Designer.</span>
            <span style="color: #008000">//</span>
            <span style="color: #2040a0">InitializeComponent</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
        <span style="color: #4444FF"><strong>}</strong></span>

<span style="color: #0000ff"><strong>		#region Web Form Designer generated code</strong></span>
        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Required method for Designer support - do not modify</span>
        <span style="color: #008000">/// the contents of this method with the code editor.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #0000FF"><strong>private</strong></span> <span style="color: #0000FF"><strong>void</strong></span> <span style="color: #2040a0">InitializeComponent</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span> <span style="color: #4444FF"><strong>{</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #008000">/// &lt;summary&gt;</span>
		<span style="color: #008000">///		Event handler for when the user clicks on the submit button.  This updates the customer </span>
		<span style="color: #008000">///		information (first name, last name, email address, password, subscription status)</span>
		<span style="color: #008000">///		based on the information specified by the user.</span>
		<span style="color: #008000">/// &lt;/summary&gt;</span>
		<span style="color: #008000">/// &lt;param name=&quot;sender&quot;&gt;Where the event came from&lt;/param&gt;</span>
		<span style="color: #008000">/// &lt;param name=&quot;e&quot;&gt;Information about the event&lt;/param&gt;</span>
		<span style="color: #0000FF"><strong>protected</strong></span> <span style="color: #0000FF"><strong>void</strong></span> <span style="color: #2040a0">UpdateButton_Click</span><span style="color: #4444FF">(</span><span style="color: #2040a0">object</span> <span style="color: #2040a0">sender</span>, <span style="color: #2040a0">ImageClickEventArgs</span> <span style="color: #2040a0">e</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">CustomersDB</span> <span style="color: #2040a0">customers</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">CustomersDB</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">String</span> <span style="color: #2040a0">passwordHash</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CustomersDB</span>.<span style="color: #2040a0">CreatePasswordHash</span><span style="color: #4444FF">(</span><span style="color: #2040a0">SettingsControl</span>.<span style="color: #2040a0">OldPasswordText</span>,
											   <span style="color: #4444FF">(</span><span style="color: #2040a0">String</span><span style="color: #4444FF">)</span><span style="color: #2040a0">Page</span>.<span style="color: #2040a0">Session</span><span style="color: #4444FF">[</span><span style="color: #444444">&quot;PWSalt&quot;</span><span style="color: #4444FF">]</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #4444FF">!</span><span style="color: #4444FF">(</span><span style="color: #2040a0">passwordHash</span>.<span style="color: #2040a0">Equals</span><span style="color: #4444FF">(</span><span style="color: #2040a0">Page</span>.<span style="color: #2040a0">Session</span><span style="color: #4444FF">[</span><span style="color: #444444">&quot;PWHash&quot;</span><span style="color: #4444FF">]</span><span style="color: #4444FF">)</span><span style="color: #4444FF">)</span><span style="color: #4444FF">)</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">SettingsControl</span>.<span style="color: #2040a0">ErrorMessage</span> <span style="color: #4444FF">=</span> <span style="color: #444444">&quot;The old password you entered does not match.&quot;</span><span style="color: #4444FF">;</span>
				<span style="color: #0000FF"><strong>return</strong></span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>

			<span style="color: #2040a0">customers</span>.<span style="color: #2040a0">UpdateCustomer</span><span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>int</strong></span>.<span style="color: #2040a0">Parse</span><span style="color: #4444FF">(</span><span style="color: #2040a0">Context</span>.<span style="color: #2040a0">User</span>.<span style="color: #2040a0">Identity</span>.<span style="color: #2040a0">Name</span><span style="color: #4444FF">)</span>,
									 <span style="color: #2040a0">SettingsControl</span>.<span style="color: #2040a0">FirstNameText</span>,
									 <span style="color: #2040a0">SettingsControl</span>.<span style="color: #2040a0">LastNameText</span>,
									 <span style="color: #2040a0">SettingsControl</span>.<span style="color: #2040a0">EmailText</span>,
									 <span style="color: #2040a0">SettingsControl</span>.<span style="color: #2040a0">PasswordText</span>,
									 <span style="color: #4444FF">(</span><span style="color: #2040a0">String</span><span style="color: #4444FF">)</span><span style="color: #2040a0">Page</span>.<span style="color: #2040a0">Session</span><span style="color: #4444FF">[</span><span style="color: #444444">&quot;PWSalt&quot;</span><span style="color: #4444FF">]</span>,
				<span style="color: #4444FF">(</span><span style="color: #2040a0">SettingsControl</span>.<span style="color: #2040a0">IsEmailPromotionChecked</span><span style="color: #4444FF">)</span> ? <span style="color: #FF0000">1</span> <span style="color: #4444FF">:</span> <span style="color: #FF0000">0</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #4444FF">!</span><span style="color: #4444FF">(</span><span style="color: #2040a0">SettingsControl</span>.<span style="color: #2040a0">PasswordText</span>.<span style="color: #2040a0">Equals</span><span style="color: #4444FF">(</span><span style="color: #2040a0">String</span>.<span style="color: #2040a0">Empty</span><span style="color: #4444FF">)</span><span style="color: #4444FF">)</span><span style="color: #4444FF">)</span>
				<span style="color: #2040a0">Page</span>.<span style="color: #2040a0">Session</span><span style="color: #4444FF">[</span><span style="color: #444444">&quot;PWHash&quot;</span><span style="color: #4444FF">]</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CustomersDB</span>.<span style="color: #2040a0">CreatePasswordHash</span><span style="color: #4444FF">(</span>
					<span style="color: #2040a0">SettingsControl</span>.<span style="color: #2040a0">PasswordText</span>,<span style="color: #4444FF">(</span><span style="color: #2040a0">String</span><span style="color: #4444FF">)</span><span style="color: #2040a0">Page</span>.<span style="color: #2040a0">Session</span><span style="color: #4444FF">[</span><span style="color: #444444">&quot;PWSalt&quot;</span><span style="color: #4444FF">]</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">SettingsControl</span>.<span style="color: #2040a0">ErrorMessage</span> <span style="color: #4444FF">=</span> <span style="color: #444444">&quot;&quot;</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">SettingsControl</span>.<span style="color: #2040a0">OnAccountSettingsUpdate</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
		<span style="color: #4444FF"><strong>}</strong></span>

<span style="color: #0000ff"><strong>		#endregion</strong></span>

    <span style="color: #4444FF"><strong>}</strong></span>
<span style="color: #4444FF"><strong>}</strong></span>

</pre>
